package pe.com.hatunsol.hatun_android.utilitario;

import java.io.UnsupportedEncodingException;
import java.nio.charset.CharacterCodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import pe.com.hatunsol.hatun_android.entity.Usuario;

/**
 * Created by Sistemas on 27/02/2015.
 */
public class Util {
    public static String Direccion_WCF = "http://www.hatunsol.com.pe/ws_hatun/";
    //public static String Direccion_WCF = "http://10.0.3.2:23843/";

    public static String EncriptarPassword(String pPassword) throws UnsupportedEncodingException, NoSuchAlgorithmException, CharacterCodingException {
        String strEncPassword = "";
        byte data[] = pPassword.getBytes("UTF-8");
        MessageDigest sha = MessageDigest.getInstance("SHA1");
        byte[] resultado = sha.digest(data);
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < resultado.length; i++) {

            sb.append(String.format("%02x", resultado[i]));
        }

        strEncPassword = sb.toString();

        return strEncPassword;
    }

    public static Usuario BE_DatosUsuario;

    public static boolean isNumber(String value) {
        if (value == null || value.isEmpty()) return false;
        try {
            Long.parseLong(value);
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
}